/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Human Booster
 */
@Entity
@Table(name = "licence_software")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "LicenceSoftware.findAll", query = "SELECT l FROM LicenceSoftware l"),
    @NamedQuery(name = "LicenceSoftware.findById", query = "SELECT l FROM LicenceSoftware l WHERE l.id = :id"),
    @NamedQuery(name = "LicenceSoftware.findByName", query = "SELECT l FROM LicenceSoftware l WHERE l.name = :name"),
    @NamedQuery(name = "LicenceSoftware.findByUseDurationLimit", query = "SELECT l FROM LicenceSoftware l WHERE l.useDurationLimit = :useDurationLimit"),
    @NamedQuery(name = "LicenceSoftware.findByLaunchCounterLimit", query = "SELECT l FROM LicenceSoftware l WHERE l.launchCounterLimit = :launchCounterLimit")})
public class LicenceSoftware implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "name")
    private String name;
    @Basic(optional = false)
    @NotNull
    @Column(name = "use_duration_limit")
    private int useDurationLimit;
    @Basic(optional = false)
    @NotNull
    @Column(name = "launch_counter_limit")
    private int launchCounterLimit;
    @JoinColumn(name = "software_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Software softwareId;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "licenceSoftwareId")
    private Collection<LicenceCustomer> licenceCustomerCollection;

    public LicenceSoftware() {
    }

    public LicenceSoftware(Integer id) {
        this.id = id;
    }

    public LicenceSoftware(Integer id, String name, int useDurationLimit, int launchCounterLimit) {
        this.id = id;
        this.name = name;
        this.useDurationLimit = useDurationLimit;
        this.launchCounterLimit = launchCounterLimit;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getUseDurationLimit() {
        return useDurationLimit;
    }

    public void setUseDurationLimit(int useDurationLimit) {
        this.useDurationLimit = useDurationLimit;
    }

    public int getLaunchCounterLimit() {
        return launchCounterLimit;
    }

    public void setLaunchCounterLimit(int launchCounterLimit) {
        this.launchCounterLimit = launchCounterLimit;
    }

    public Software getSoftwareId() {
        return softwareId;
    }

    public void setSoftwareId(Software softwareId) {
        this.softwareId = softwareId;
    }

    @XmlTransient
    public Collection<LicenceCustomer> getLicenceCustomerCollection() {
        return licenceCustomerCollection;
    }

    public void setLicenceCustomerCollection(Collection<LicenceCustomer> licenceCustomerCollection) {
        this.licenceCustomerCollection = licenceCustomerCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof LicenceSoftware)) {
            return false;
        }
        LicenceSoftware other = (LicenceSoftware) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.LicenceSoftware[ id=" + id + " ]";
    }
    
}
